package com.whl215.kit.grape

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.whl215.kit.grape.databinding.ActivityMainBinding
import com.whl215.kit.grape.ui.QuickAdapterActivity
import com.whl215.kit.grape.ui.ShopCartActivity

class MainActivity : AppCompatActivity(), View.OnClickListener {
    private lateinit var mViewBinding: ActivityMainBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mViewBinding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(mViewBinding.root)
        mViewBinding.btnGoQuickAdapter.setOnClickListener(this)
        mViewBinding.btnGoShopCart.setOnClickListener(this)
    }

    override fun onClick(p0: View?) {
        when (p0?.id) {
            R.id.btn_go_quick_adapter -> {
                jumpActivity(QuickAdapterActivity::class.java)
            }
            R.id.btn_go_shop_cart ->{
                jumpActivity(ShopCartActivity::class.java)
            }
        }
    }

    private fun jumpActivity(clazz: Class<*>) {
        val intent = Intent(this, clazz)
        startActivity(intent)
    }
}